package com.jie.lipassword;

import android.app.Activity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.TwoLineListItem;

import androidx.appcompat.app.AppCompatActivity;

public class FindTitle extends AppCompatActivity {
    private static ImageView title_back;
    private static TextView title_view;
    private static ImageView title_more;
    private static LinearLayout title_fun_list;
    private static TextView Backup;
    private static Boolean is_fun_list = false;

    public static void setTitle(Activity Athis, RelativeLayout main_title, Boolean is_back, Boolean is_more, String title_text){
        title_view = main_title.findViewById(R.id.title);
        title_back = main_title.findViewById(R.id.title_back_icon);
        title_more = main_title.findViewById(R.id.title_more_icon);
        title_fun_list = main_title.findViewById(R.id.title_fun_list);

        //定义标题名称
        title_view.setText(title_text);
        //按钮是否隐藏
        title_back.setVisibility(is_back?View.VISIBLE:View.GONE);
        title_more.setVisibility(is_more?View.VISIBLE:View.GONE);
        title_fun_list.setVisibility(is_fun_list?View.VISIBLE:View.GONE);
        is_fun_list = false;

        // 功能列表
        Backup = main_title.findViewById(R.id.Backup);
        Backup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                
            }
        });

        // 点击事件
        title_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 创建并显示一个短时吐司
//                Toast.makeText(view.getContext(), "返回按钮被点击", Toast.LENGTH_SHORT).show();
                Athis.finish();
            }
        });
        title_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                is_fun_list = !is_fun_list;
                title_fun_list.setVisibility(is_fun_list?View.VISIBLE:View.GONE);
            }
        });
    }
}
